home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / tcl / xf2.3-p / xf2 / xf2.3 / additionals / Dial < prev    next >
Encoding:
Text File  |  1993-11-20  |  8.8 KB  |  249 lines

  1. # Program: xf
  2. # Description: handle dial widgets
  3. #
  4. # $Header: Dial[2.3] Wed Mar 10 11:57:20 1993 garfield@garfield frozen $
  5.  
  6. global xfDefaultConf
  7. set xfDefaultConf(dial) 4
  8.  
  9. ##########
  10. # Procedure: XFAdd.Dial
  11. # Description: add a dial
  12. # Arguments: xfW - the widget
  13. #            xfName - a optional name
  14. #            xfType - add or config
  15. # Returns: none
  16. # Sideeffects: none
  17. ##########
  18. proc XFAdd.Dial {xfW xfName xfType} {
  19.   global xfStatus
  20.  
  21.   XFEditSetStatus "Inserting Dial..."
  22.   set xfName [XFMiscGetUniqueName $xfName dial]
  23.   if {"$xfStatus(path)" == "."} {
  24.     if {"$xfType" == "add"} {
  25.       if {[catch "dial .$xfName" xfResult]} {
  26.         XFProcError "$xfResult"
  27.         XFEditSetStatus "Inserting Dial...aborted"
  28.         return
  29.       }
  30.     } {
  31.       if {[catch "dial .$xfName" xfResult]} {
  32.         XFProcError "$xfResult"
  33.         XFEditSetStatus "Inserting Dial...aborted"
  34.         return
  35.       }
  36.     }
  37.  
  38.     XFMiscPositionWidget .$xfName
  39.     XFMiscBindWidgetTree .$xfName
  40.   } {
  41.     if {"$xfType" == "add"} {
  42.       if {[catch "dial $xfStatus(path).$xfName" xfResult]} {
  43.         XFProcError "$xfResult"
  44.         XFEditSetStatus "Inserting Dial...aborted"
  45.         return
  46.       }
  47.     } {
  48.       if {[catch "dial $xfStatus(path).$xfName" xfResult]} {
  49.         XFProcError "$xfResult"
  50.         XFEditSetStatus "Inserting Dial...aborted"
  51.         return
  52.       }
  53.     }
  54.  
  55.     XFMiscPositionWidget $xfStatus(path).$xfName
  56.     XFMiscBindWidgetTree $xfStatus(path).$xfName
  57.   }
  58.  
  59.   incr xfStatus(elementCounter)
  60.   XFEditSetPath $xfStatus(path)
  61.   XFEditSetStatus "Inserting Dial...done"
  62. }
  63.  
  64. ##########
  65. # Procedure: XFConfig.Dial4
  66. # Description: configure a dial
  67. # Arguments: xfW - the widget
  68. #            xfType - config type (add or config)
  69. #            xfClass - the class we configure
  70. #            xfLeader - the leading window
  71. # Returns: none
  72. # Sideeffects: none
  73. ##########
  74. proc XFConfig.Dial4 {xfW xfType xfClass {xfLeader ""}} {
  75.   global xfStatus
  76.  
  77.   if {"$xfType" == "add"} {
  78.     set xfName dial$xfStatus(elementCounter)
  79.   } {
  80.     set xfName [XFMiscPathName $xfW]
  81.   }
  82.   XFEditSetStatus "Calling parameter setting for Dial..."
  83.  
  84.   # build widget structure
  85.   XFTmpltToplevel .xf${xfClass}Config4 400x640 \
  86.     "Dial parameters:[XFMiscPathTail $xfW]" $xfLeader
  87.  
  88.   XFElementInit $xfW .xf${xfClass}Config4 $xfType $xfClass \
  89.     XFDialSetDial4 parameters $xfName 4
  90.   XFElementColor $xfW .xf${xfClass}Config4 $xfType $xfClass bg \
  91.     background Background "Background" XFDialSetDial4
  92.   XFElementScaleDouble $xfW .xf${xfClass}Config4 $xfType \
  93.     $xfClass degree "Degree" "Begin" "End" 360 360
  94.   XFElementText $xfW .xf${xfClass}Config4 $xfType $xfClass interval \
  95.     interval Interval "Interval" XFDialSetDial4
  96.   XFElementColor $xfW .xf${xfClass}Config4 $xfType $xfClass majortickcolor \
  97.     majortickcolor Foreground "Major tick color" XFDialSetDial4
  98.   XFElementColor $xfW .xf${xfClass}Config4 $xfType $xfClass needlecolor \
  99.     needlecolor Foreground "Needle color" XFDialSetDial4
  100.   XFElementScale $xfW .xf${xfClass}Config4 $xfType $xfClass radius \
  101.     radius Radius "Radius" "pixels" 400 XFDialSetDial4
  102.   XFElementBoolean $xfW .xf${xfClass}Config4 $xfType $xfClass showvalue \
  103.     "Show value" XFDialSetDial4
  104.   XFElementText $xfW .xf${xfClass}Config4 $xfType $xfClass title \
  105.     title Title "Text" XFDialSetDial4
  106.   XFElementColor $xfW .xf${xfClass}Config4 $xfType $xfClass textcolor \
  107.     textcolor Foreground "Text color" XFDialSetDial4
  108.   XFElementColor $xfW .xf${xfClass}Config4 $xfType $xfClass tickcolor \
  109.     tickcolor Foreground "Tick color" XFDialSetDial4
  110.   XFElementScaleDouble $xfW .xf${xfClass}Config4 $xfType \
  111.     $xfClass ticks "Ticks" "Total" "Major" 500 250
  112.   XFElementScaleDouble $xfW .xf${xfClass}Config4 $xfType \
  113.     $xfClass value "Value" "Min" "Max" 2000 2000
  114.   XFElementCommand $xfW .xf${xfClass}Config4 $xfType
  115.   
  116.   .xf${xfClass}Config4.params1.params2.degree.degree1.degree1 set \
  117.     [lindex [$xfW config -begindegree] 4]
  118.   .xf${xfClass}Config4.params1.params2.degree.degree2.degree2 set \
  119.     [lindex [$xfW config -enddegree] 4]
  120.   .xf${xfClass}Config4.params1.params2.ticks.ticks1.ticks1 set \
  121.     [lindex [$xfW config -numticks] 4]
  122.   .xf${xfClass}Config4.params1.params2.ticks.ticks2.ticks2 set \
  123.     [lindex [$xfW config -majorticks] 4]
  124.   .xf${xfClass}Config4.params1.params2.value.value1.value1 set \
  125.     [lindex [$xfW config -minvalue] 4]
  126.   .xf${xfClass}Config4.params1.params2.value.value2.value2 set \
  127.     [lindex [$xfW config -maxvalue] 4]
  128.  
  129.   XFMiscSetResource \
  130.     .xf${xfClass}Config4.params1.params2.degree.degree1.degree1 \
  131.       command "XFDialSetDial4 $xfW 0 $xfClass"
  132.   XFMiscSetResource \
  133.     .xf${xfClass}Config4.params1.params2.degree.degree2.degree2 \
  134.       command "XFDialSetDial4 $xfW 0 $xfClass"
  135.   XFMiscSetResource \
  136.     .xf${xfClass}Config4.params1.params2.ticks.ticks1.ticks1 \
  137.       command "XFDialSetDial4 $xfW 0 $xfClass"
  138.   XFMiscSetResource \
  139.     .xf${xfClass}Config4.params1.params2.ticks.ticks2.ticks2 \
  140.       command "XFDialSetDial4 $xfW 0 $xfClass"
  141.   XFMiscSetResource \
  142.     .xf${xfClass}Config4.params1.params2.value.value1.value1 \
  143.       command "XFDialSetDial4 $xfW 0 $xfClass"
  144.   XFMiscSetResource \
  145.     .xf${xfClass}Config4.params1.params2.value.value2.value2 \
  146.       command "XFDialSetDial4 $xfW 0 $xfClass"
  147.  
  148.   # save current parameter
  149.   XFElementSave $xfW $xfClass {background begindegree enddegree interval majortickcolor needlecolor radius showvalue textcolor tickcolor title maxvalue minvalue numticks majorticks command}
  150.  
  151.   # packing
  152.   pack append .xf${xfClass}Config4.params1 \
  153.               .xf${xfClass}Config4.params1.params2 {left fill expand}
  154.   pack append .xf${xfClass}Config4 \
  155.               .xf${xfClass}Config4.pathname {top fill frame center} \
  156.               .xf${xfClass}Config4.leave {bottom fill} \
  157.               .xf${xfClass}Config4.additional {bottom fill} \
  158.               .xf${xfClass}Config4.params1 {top fill expand}
  159.  
  160.   XFBindFormConnect .xf${xfClass}Config4.params1.params2 \
  161.     "XFDialSetDial4 $xfW 0 $xfClass"
  162.  
  163.   XFEditSetStatus "Calling parameter setting for Dial...done"
  164. }
  165.  
  166. ##########
  167. # Procedure: XFSaveSpecial.Dial
  168. # Description: save dial
  169. # Arguments: xfW - the widget
  170. # Returns: none
  171. # Sideeffects: none
  172. ##########
  173. proc XFSaveSpecial.Dial {xfW} {
  174.  
  175.   return "\n  $xfW set [$xfW get]"
  176. }
  177.  
  178. ##########
  179. # Procedure: XFDialSetDial4
  180. # Description: set dial parameters
  181. # Arguments: xfW - the widget
  182. #            xfType - the type of setting (1 = set always, 0 = set
  183. #                     only if permanent apply is on)
  184. #            xfClass - the class we configure
  185. #            xfParam1 - ignored parameter
  186. # Returns: none
  187. # Sideeffects: none
  188. ##########
  189. proc XFDialSetDial4 {xfW xfType xfClass {xfParam1 ""}} {
  190.   global xfConf
  191.   global xfMisc
  192.  
  193.   if {$xfType == 0 && !$xfConf(applyParameters)} {
  194.     return
  195.   }
  196.   if {"[info commands $xfW]" == ""} {
  197.     return
  198.   }
  199.   XFMiscSetSymbolicName $xfW \
  200.     [.xf${xfClass}Config4.params1.params2.symname.symname get]
  201.  
  202.   XFMiscSetResource $xfW background \
  203.     [.xf${xfClass}Config4.params1.params2.bg.bg get]
  204.   XFMiscSetResource $xfW begindegree \
  205.     [.xf${xfClass}Config4.params1.params2.degree.degree1.degree1 get]
  206.   XFMiscSetResource $xfW enddegree \
  207.     [.xf${xfClass}Config4.params1.params2.degree.degree2.degree2 get]
  208.   XFMiscSetResource $xfW command \
  209.     [XFMiscGetText .xf${xfClass}Config4.params1.params2.command.command.command]
  210.   if {"[.xf${xfClass}Config4.params1.params2.interval.interval get]" != ""} {
  211.     XFMiscSetResource $xfW interval \
  212.       [.xf${xfClass}Config4.params1.params2.interval.interval get]
  213.   } {
  214.     XFMiscSetResource $xfW interval 0
  215.   }
  216.   XFMiscSetResource $xfW maxvalue \
  217.     [.xf${xfClass}Config4.params1.params2.value.value2.value2 get]
  218.   XFMiscSetResource $xfW minvalue \
  219.     [.xf${xfClass}Config4.params1.params2.value.value1.value1 get]
  220.   if {"[.xf${xfClass}Config4.params1.params2.majortickcolor.majortickcolor get]" != ""} {
  221.     XFMiscSetResource $xfW majortickcolor \
  222.       [.xf${xfClass}Config4.params1.params2.majortickcolor.majortickcolor get]
  223.   }
  224.   XFMiscSetResource $xfW majorticks \
  225.     [.xf${xfClass}Config4.params1.params2.ticks.ticks2.ticks2 get]
  226.   if {"[.xf${xfClass}Config4.params1.params2.needlecolor.needlecolor get]" != ""} {
  227.     XFMiscSetResource $xfW needlecolor \
  228.       [.xf${xfClass}Config4.params1.params2.needlecolor.needlecolor get]
  229.   }
  230.   XFMiscSetResource $xfW numticks \
  231.     [.xf${xfClass}Config4.params1.params2.ticks.ticks1.ticks1 get]
  232.   XFMiscSetResource $xfW radius \
  233.     [.xf${xfClass}Config4.params1.params2.radius.radius get]
  234.   XFMiscSetResource $xfW showvalue $xfMisc(showvalue)
  235.   if {"[.xf${xfClass}Config4.params1.params2.textcolor.textcolor get]" != ""} {
  236.     XFMiscSetResource $xfW textcolor \
  237.       [.xf${xfClass}Config4.params1.params2.textcolor.textcolor get]
  238.   }
  239.   if {"[.xf${xfClass}Config4.params1.params2.tickcolor.tickcolor get]" != ""} {
  240.     XFMiscSetResource $xfW tickcolor \
  241.       [.xf${xfClass}Config4.params1.params2.tickcolor.tickcolor get]
  242.   }
  243.   XFMiscSetResource $xfW title \
  244.     [.xf${xfClass}Config4.params1.params2.title.title get]
  245. }
  246.  
  247. # eof
  248.  
  249.